{% extends "base.html" %}

{% block header %}
    <h1>Goals</h1>
{% endblock %}

{% block content %}
    {% if not goal %}
        <h2>Create goal</h2><br/><br/>
    {% else %}
        <h2>Edit {{ goal.name }}</h2><br/><br/>
    {% endif %}
    {% load form %}
    {% if form.errors %}
        <p style="color: red;">
            Please correct the error{{ form.errors|pluralize }} below.
        </p>
    {% endif %}

    <form action="/goals/add/" method="post"> {% csrf_token %}
        {{ form.non_field_errors }}
        <fieldset class="control-group">
            <table border="0" width="100%">
                {{ form|as_table }}
            </table>
            <hr style="color:#666666;border:outset;">
            <button class="btn" type="submit">
                <i class="icon-ok"></i>
                {% if goal %}
                    Save changes
                {% else %}
                    Create this goal
                {% endif %}
            </button>
            or <a href="/goals/">cancel</a>
            {% if goal %}
                <br/><br/>
                <a href="/goals/delete/{{ goal.pk }}/"><img src="{{ STATIC_URL }}img/remove.png"/> Delete this goal</a>
            {% endif %}
        </fieldset>
    </form>
{% endblock content %}